﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>菜单管理</title>
    <#include "/common/link.ftl">


    <script>
        $(function () {
            //选择目录时禁用上级菜单和URL
            $('#directoryChange').click(function () {
                $('#parentIdSelect').prop('disabled',true);
                $('#parentIdSelect').val('');
                $('#menuUrlSelect').prop('disabled',true);
                $('#menuUrlSelect').val('');
            });
            //选择菜单时解放
            $('#menuChange').click(function () {
                $('#parentIdSelect').prop('disabled',false);
                $('#menuUrlSelect').prop('disabled',false);
            });


            //编辑回显
            $('.btn-input').click(function () {

                //清空表单
                $('#editForm').clearForm(true);
                $("#parentIdSelect").val("");

                var json=$(this).data('json');
                if (json){
                    $("#editModal input[name='id']").val(json.id);
                    $("#editModal input[name='menuType'][value="+json.menuType+"]").prop('checked',true);
                    $("#editModal input[name='name']").val(json.name);
                    $("#editModal select[name='parentId']").val(json.parentId);
                    $("#editModal input[name='menuUrl']").val(json.menuUrl);
                }
                $("#editModal").modal('show')
            });

            //启用按钮
            $('.btn-status').click(function () {
                var status = $(this).data("status"); //获取启用状态
                var id = $(this).data("id");//获取当前菜单id
                var msg = "是否确认启用该菜单?";
                if (status == 0) {
                    msg = "是否确认禁用该菜单?"
                }
                Swal.fire({
                    title: msg,
                    text: "该操作不可撤销",
                    icon: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消'
                }).then((result) => {
                    if (result.value) {
                        // 点了确定做什么，由开发者决定
                        window.location.href="/systemMenu/updateStatus?id="+id+"&status="+status;
                    }
                });
            });

        });
    </script>

</head>
<body class="hold-transition skin-black sidebar-mini">
<div class="wrapper">
    <#include "/common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="systemMenu"/>
    <#include "/common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>菜单管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <div style="margin: 20px 0px 0px 10px">
                    <form class="form-inline" id="searchForm" action="/systemMenu/list" method="post">
                        <input type="hidden" name="currentPage" id="currentPage" value="1">
                        <div class="form-group">
                            <label>菜单名称</label>
                            <input type="text" class="form-control"  placeholder="请输入菜单名称" name="name" value="${qo.name}">
                        </div>
                            <div class="form-group">
                                <label>菜单地址</label>
                                <input type="text" class="form-control"  placeholder="请输入菜单地址" name="menuUrl" value="${qo.menuUrl}">
                            </div>
                            <div class="form-group">
                                <label>菜单状态</label>
                                <select class="form-control" name="menuStatus" id="menuStatusSelect">
                                    <option value="-1">全部</option>
                                    <option value="1">启动</option>
                                    <option value="0">禁用</option>
                                </select>
                                <script>
                                    $('#menuStatusSelect').val(${qo.menuStatus!})
                                </script>
                            </div>
                            <div class="form-group">
                                <label>菜单类型</label>
                                <select class="form-control" name="menuType" id="menuTypeSelect">
                                    <option value="-1" >全部</option>
                                    <option value="0">目录</option>
                                    <option value="1">菜单</option>
                                </select>
                                <script>
                                    $('#menuTypeSelect').val(${qo.menuType!})
                                </script>
                            </div>

                        <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> 查询</button>

                        <a href="#" class="btn btn-success btn-input">
                            <span class="glyphicon glyphicon-plus"></span> 添加
                        </a>
                    </form>

                </div>
                <div class="box-body table-responsive ">
                <table class="table table-hover table-bordered table-striped">
                    <thead>
                    <tr>
                        <th>编号</th>
<#--                        <th>菜单图标</th>-->
                        <th>菜单类型</th>
                        <th>菜单名称</th>
                        <th>上级菜单</th>
                        <th>菜单URL</th>
                     <#--   <th>权限表达式</th>-->
                       <#-- <th>排序</th>-->
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <#list pageInfo.list as p>
                    <tr>
                        <td>${p_index+1}</td>
<#--                        <td> <i class="fa fa-dashboard"></i></td>-->
                        <td>${p.menuTypeDisplay!}</td>
                        <td>${p.name!}</td>
                        <td>${p.parentName!}</td>
                        <td>${p.menuUrl!}</td>
                       <#-- <td>${p.menuExpression}</td>-->
                        <td>${p.menuStatusDisplay!}</td>
                        <td>
                            <a href="#" class="btn btn-info btn-xs btn-input" data-json='${p.toJson()}'>
                                <span class="glyphicon glyphicon-pencil"></span> 编辑
                            </a>
                            <a class="btn btn-xs btn-primary btn-status" data-status="1" data-id="${p.id}">
                                <span class="glyphicon glyphicon-phone-alt"></span> 启用</a>
                            <a class="btn btn-xs btn-danger btn-status" data-status="0" data-id="${p.id}">
                                <span class="glyphicon glyphicon-remove"></span> 禁用</a>
                        </td>
                    </tr>
                    </#list>
                    </tbody>
                </table>
                    <!--分页-->
                    <#include "/common/page.ftl">
                </div>

            </div>
        </section>
    </div>
    <#include "/common/footer.ftl">
</div>


<!-- Modal -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" >
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel">新增/编辑</h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
            </div>

            <form id="editForm" action="/systemMenu/saveOrUpdate" method="post">
                <div class="modal-body">
                    <input type="hidden" name="id">
                    <div class="form-group row">
                        <label class="col-sm-3 col-form-label">菜单类型：</label>
                        <div class="col-sm-7">
                            <label>
                                <input type="radio" name="menuType"  id="directoryChange" value="0">
                                目录
                            </label>
                            <label>
                                <input type="radio" name="menuType"  value="1" id="menuChange">
                                菜单
                            </label>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-3 col-form-label">菜单名称：</label>
                        <div class="col-sm-7">
                            <input type="text"  class="form-control " placeholder="请输入菜单名称" name="name"/>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-sm-3 col-form-label">上级菜单：</label>
                        <div class="col-sm-7">
                            <select class="form-control" name="parentId" id="parentIdSelect">
                                <option value="">无</option>
                                <#list menu as m>
                                    <option value="${m.id}">${m.name}</option>
                                </#list>
                            </select>

                        </div>
                    </div>
                    <script>

                    </script>
                    <div class="form-group row">
                        <label class="col-sm-3 col-form-label">菜单URL：</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control"
                                   placeholder="请输入菜单URL" name="menuUrl" id="menuUrlSelect">
                        </div>
                    </div>
                   <#-- <div class="form-group row">
                        <label class="col-sm-3 col-form-label">菜单序号：</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control"
                                   placeholder="请输入菜单序号">
                        </div>
                    </div>-->
                  <#--  <div class="form-group row">
                        <label class="col-sm-3 col-form-label">菜单图标：</label>
                        <div class="col-sm-7" style="color:lightslategrey">
                                <label>
                                    <input type="radio" name="b"  value="fa fa-dashboard" checked>
                                    <i class="fa fa-dashboard"></i>
                                </label>
                                <label>
                                    <input type="radio" name="b"  value="fa fa-pie-chart">
                                    <i class="fa fa-pie-chart"></i>
                                </label>
                                <label>
                                    <input type="radio" name="b" value="fa fa-joomla" >
                                    <i class="fa fa-joomla"></i>
                                </label>
                                <label>
                                    <input type="radio" name="b"  value="fa fa-files-o" checked>
                                    <i class="fa fa-files-o"></i>
                                </label>
                                <label>
                                    <input type="radio" name="b"  value="fa fa-edit">
                                    <i class="fa fa-edit"></i>
                                </label>
                                <label>
                                    <input type="radio" name="b" value="fa fa-laptop" >
                                    <i class="fa fa-laptop"></i>
                                </label>
                                <label>
                                    <input type="radio" name="b" value="fa fa-laptop" >
                                    <i class="fa fa-circle-o"></i>
                                </label>
                        </div>

                    </div>-->
                    <#--<div class="form-group row">
                        <label class="col-sm-3 col-form-label">权限表达式：</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control"
                                   placeholder="请输入权限表达式">
                        </div>
                    </div>-->
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary btn-submit">保存</button>
                </div>
            </form>
        </div>
    </div>
</div>


</body>
</html>
